PostgreSQL: Only rollback when in a transaction
authorJeff <jeff.janes@gmail.com>
Fri, 30 May 2014 06:42:41 +0000 (23:42 -0700)
committerJeff <jeff.janes@gmail.com>
Fri, 30 May 2014 06:51:57 +0000 (23:51 -0700)
SQL errors would issue a rollback, even when it was
not actually in a transactions.  Doing so would cause
another error to be reported.  This could obscure the
original error, particularly during unit tests.

Fix this by not rolling back when not in a transaction.

Bug: 58095
Change-Id: Ib5220e37dd6c364feee6b7f8e7ecbdae2a2e0ba1

includes/db/DatabasePostgres.php

index 1cbd1e2..3d7267a 100644 (file)
@@ -521,7 +521,6 @@ class DatabasePostgres extends DatabaseBase {
        }
 
        function reportQueryError( $error, $errno, $sql, $fname, $tempIgnore = false ) {
-               /* Transaction stays in the ERROR state until rolledback */
                if ( $tempIgnore ) {
                        /* Check for constraint violation */
                        if ( $errno === '23505' ) {
@@ -530,8 +529,10 @@ class DatabasePostgres extends DatabaseBase {
                                return;
                        }
                }
-               /* Don't ignore serious errors */
-               $this->rollback( __METHOD__ );
+               /* Transaction stays in the ERROR state until rolledback */
+               if ( $this->mTrxLevel ) {
+                       $this->rollback( __METHOD__ );
+               };
                parent::reportQueryError( $error, $errno, $sql, $fname, false );
        }